import request from '../request/request.ts'

//根据标签列表返回用户列表
export const getUsersByTags = async (tagNameList:any) =>  {
    return await request({
        url: '/service/user/getUsersByTags',
        method: 'post',
        data:JSON.stringify(tagNameList),
        headers: {
            'Content-Type': 'application/json'
        },
        // params:{
        //     tagNameList: data
        // },
        // paramsSerializer: params => {
        //     return qs.stringify(params,{indices: false})
        // }

    });
}

//获取当前用户(redis中获取session) // 使用阻塞 const res = await getCurrentUserAPI();拿到res才进行下一步
export const getCurrentUserAPI = () => {
    return request({
        url: '/service/user/current',
        method: 'get'
    });
}

//更新用户信息
export const updateUserInfo =  (data:any) => {
    return request({
        url: '/service/user/updateUser',
        method: 'put',
        data: data
    });
}

//推荐用户(主页)
export const getRecommend = (limit:string,pageSize:string) =>{
    return request({
        url: '/service/user/recommend',
        method: 'get',
        params: {
            limit : limit,
            pageSize : pageSize
        }
    });
}

//心动用户(主页)
export const getMatch = (num:any) =>{
    return request({
        url: '/service/user/match',
        method: 'get',
        params: {
            num : num
        }
    });
}

//注册——邮箱
export const registerEmail = (data:any) =>{
    return request({
        url: '/service/user/register/toEmail',
        method: 'post',
        data: data
    });
}

//注册——手机号
export const registerPhone = (data:any) =>{
    return request({
        url: '/service/user/register/toPhone',
        method: 'post',
        data: data
    });
}


//登录——邮箱
export const loginEmail = (data:any) =>{
    return request({
        url: '/service/user/login/email',
        method: 'post',
        data: data
    });
}

//登录——账户方式
export const loginAccount = (data:any) =>{
    return request({
        url: '/service/user/login/account',
        method: 'post',
        data: data
    });
}

//登录——手机号方式
export const loginPhone = (data:any) =>{
    return request({
        url: '/service/user/login/phone',
        method: 'post',
        data: data
    });
}

//获取验证码图片
export const getLoginCodeByCaptcha = () =>{
    return request({
        url: '/service/user/login/captcha',
        method: 'get',
    });
}


//更新标签 + 更新状态，注册后完成填写信息=》status=1-》status=0
export const updateUserTags = (updateRequest:any) =>{
    return request({
        url: '/service/user/updateUserTags',
        method: 'post',
        data: updateRequest
    });
}

//退出登录
export const quitLogin = ()=>{
    return request({
        url: '/service/user/logout',
        method:"post"
    });
}

//根据Id查询用户信息
export const selectUserById =(uid:any)=>{
    return request({
        url: '/service/user/selectUserById',
        method:"get",
        params:{
            id:uid
        }
    });
}


//根据Account查询用户信息
export const selectUserByAccount =(account:any)=>{
    return request({
        url: '/service/user/selectUserByAccount',
        method:"get",
        params:{
            account:account
        }
    });
}

//根据一批id查询用户信息
export const selectUsersByIds =(ids:any)=>{
    return request({
        url: '/service/user/selectUsersByIds',
        method:"post",
        data:ids
    });
}
